package com.gm.wj.dao;

import com.gm.wj.entity.AdminRole;
import com.gm.wj.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author Evan
 * @date 2019/11
 */
public interface AdminRoleDAO extends JpaRepository<AdminRole, Integer> {
    AdminRole findById(int id);
    // 多条件模糊查询
    @Query(value = "select * from admin_role  where  (?1 is null or enabled  like ?1) and (?2 is null or name_zh like ?2) ",nativeQuery = true)
    List<AdminRole> find(String queryKey1, String queryKey2);

    @Query(value = "select * from admin_role  where  (?1 is null or roleName  like ?1) ",nativeQuery = true)
    int findByRoleName(String roleName);

    @Query(value = "select * from admin_role  where  enabled  like '1' ",nativeQuery = true)
    List<AdminRole> findAllByEnabled();

}
